package com.ruoyi.project.cms.mm.move.service;

import com.ruoyi.project.cms.mm.move.domain.Move;
import com.ruoyi.project.cms.mm.move.mapper.MoveMapper;
import com.ruoyi.project.cms.mm.task.mapper.TaskInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator
 * @create 2020-05-19 9:28
 * @desc MoveService实现类
 **/
@Service
public class MoveServiceImpl implements MoveService {
    @Autowired
    private MoveMapper moveMapper;

    @Autowired
    private TaskInfoMapper taskInfoMapper;

    @Override
    public List<Move> selectMoreMoves(Move move) {
        return moveMapper.selectList(move);
    }

    @Override
    public Integer addMove(Move move) {
        return moveMapper.insert(move);
    }

    @Override
    public Integer deleteByMid(String mid) {
        return moveMapper.deleteByMid(mid);
    }

    @Override
    public Move selectOneByMid(Integer mid) {
        return moveMapper.selectOneByMid(mid);
    }

    @Override
    public int edit(Move move) {
        return moveMapper.update(move);
    }

    @Override
    public List<Move> selectByNextAndStatus(String nextauditor, int status) {
        return moveMapper.selectByNextAndStatus(nextauditor,status);
    }

    @Override
    public Integer doApprv(Move move) {
        move.setStatus(2);
        Integer integer = moveMapper.updateApprv(move);
        System.out.println("move"+move);
//        判断审批意见
        if (move.getOpinion() == 0) {
//            如果意见为同意，那么就将ologname更新到taskInfo表中
            Integer result = taskInfoMapper.updateDlogname(move.getOlogname(),move.getTid());
        }
        return integer;
    }

    @Override
    public Move selectByTid(Integer tid,String alogname) {
        return moveMapper.selectByTid(tid,alogname);
    }
}
